using UnityEngine;

public class WeaponAudio : MonoBehaviour
{
	public AudioClip soundDamage;

	[HideInInspector]
	public float volumeDamage = 1f;

	public AudioClip soundHit;

	[HideInInspector]
	public float volumeHit = 1f;

	public AudioClip soundReload;

	[HideInInspector]
	public float volumeReload = 1f;

	public AudioClip soundShoot;

	[HideInInspector]
	public float volumeShoot = 1f;

	public AudioClip soundEmpty;

	[HideInInspector]
	public float volumeEmpty = 1f;

	[HideInInspector]
	private AudioSource cashAudio;

	private void Start()
	{
		if (cashAudio == null)
		{
			cashAudio = GetComponent<AudioSource>();
		}
		BaseWeapon component = GetComponent<BaseWeapon>();
		component.AddEventListener(this, "NoAmmo", delegate
		{
			Play(soundEmpty, volumeEmpty);
		}, false);
		component.AddEventListener(this, "Reload", delegate
		{
			Play(soundReload, volumeReload);
		}, false);
		component.AddEventListener(this, "EndReload", delegate
		{
			Play(soundDamage, volumeDamage);
		}, false);
		component.AddEventListener(this, "Shoot", delegate
		{
			Play(soundShoot, volumeShoot);
		}, false);
		component.AddEventListener(this, "Hit", delegate
		{
			Play(soundHit, volumeHit);
		}, false);
		component.AddEventListener(this, "Damage", delegate
		{
			Play(soundDamage, volumeDamage);
		}, false);
	}

	private void Play(AudioClip clip, float volume = 1f)
	{
		if ((bool)clip)
		{
			cashAudio.PlayOneShot(clip, volume * VolumeController.VolumeSound);
		}
	}

	private void OnDestroy()
	{
		if (cashAudio != null)
		{
			cashAudio.Stop();
		}
	}

	private void Update()
	{
	}
}
